package collectionTest;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author shentianyu
 * @date 2021-06-07 23:04
 *
 * Collection保存学生信息
 *
 */
public class CollectionDemo {
    public static void main(String[] args) {
        //新建Collection对象
        Collection collection = new ArrayList();
        Student student1 = new Student("张三",18);
        Student student2 = new Student("李四",19);
        Student student3 = new Student("王五",20);
        //添加
        collection.add(student1);
        collection.add(student2);
        collection.add(student3);
        System.out.println(collection.size());
        System.out.println(collection);
        //删除
        collection.remove(student1);
        System.out.println(collection.size());
        System.out.println(collection);

        System.out.println(collection.contains(new Student("王五",20)));

    }
}
